﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DepartmentList.ascx.cs" Inherits="DepartmentList" %>
<asp:GridView ID="GridView_dpt" runat="server" 
    DataSourceID="ObjectDataSource_dpt" DataKeyNames="Id" 
    AutoGenerateColumns="False" OnRowUpdating="GridView_dpt_RowUpdating" 
    onrowdatabound="GridView_dpt_RowDataBound">
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="编号" ReadOnly="True" />
        <asp:BoundField DataField="Name" HeaderText="名称" ReadOnly="True" />
        <asp:BoundField DataField="LeaderName" HeaderText="主管" />
        <asp:TemplateField HeaderText="上级领导">
            <ItemTemplate>
                <%# GetStaffBySN(Eval("DirectorSN"))%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="DropDownList_Directors" runat="server" DataSourceID="ObjectDataSource_Directors"
                    DataTextField="Name" DataValueField="SerialNumber">
                </asp:DropDownList>
                
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
    </Columns>
    <FooterStyle CssClass="FooterStyle" />
    <RowStyle CssClass="RowStyle" />
    <EmptyDataRowStyle CssClass="EmptyRowStyle" />
    <PagerStyle CssClass="PagerStyle" />
    <SelectedRowStyle CssClass="SelectedRowStyle" />
    <HeaderStyle CssClass="HeaderStyle" />
    <EditRowStyle CssClass="EditRowStyle" />
    <AlternatingRowStyle CssClass="AltRowStyle" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource_dpt" runat="server" SelectMethod="GetDepartments"
    TypeName="Departmentdb" DataObjectTypeName="DepartmentDetail" DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" UpdateMethod="UpdateDepartment"></asp:ObjectDataSource>
<br />
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="ObjectDataSource_dpt"
    Height="26px" Width="109px" AutoGenerateRows="False" OnItemCommand="DetailsView1_ItemCommand" OnItemInserted="DetailsView1_ItemInserted" OnItemInserting="DetailsView1_ItemInserting">
    <Fields>
        <asp:CommandField ShowInsertButton="True" />
        <asp:BoundField DataField="Name" HeaderText="名称" Visible="False" />
        <asp:BoundField DataField="LeaderName" HeaderText="科长/主任" Visible="False" />
    </Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource_Directors" runat="server" SelectMethod="GetStaffs"
    TypeName="StaffDB">
    <SelectParameters>
        <asp:Parameter DefaultValue="1" Name="DepartmentNum" />
    </SelectParameters>
</asp:ObjectDataSource>
